<?php
/**
 * 管理员日志控制器
 * @author maniac
 */
namespace app\manage\controller;

use app\common\model\Users;

class UserLogs extends Base
{
    /**
     * 列表页附件
     * @param  array $data 列表页数据
     */
    public function indexAttach($data)
    {
        $users = Users::field('id,username')->order('id ASC')->select();
        $this->assign('users', $users);
    }
    
    /**
     * where 查询条件
     */
    public function where()
    {
        $userid    = input('get.userid/d', 0);
        $startTime = input('get.start_time/s', '');
        $endTime   = input('get.end_time/s', '');
        $where     = [];
        if ($userid) {
            $where[] = [
                ['userid', 'eq', $userid],
            ];
        }
        if ($startTime) {
            $where[] = [
                ['date_time', 'egt', strtotime($startTime)],
            ];
        }
        if ($endTime) {
            $where[] = [
                ['date_time', 'lt', strtotime($endTime)],
            ];
        }
        $this->assign('userid', $userid);
        $this->assign('startTime', $startTime);
        $this->assign('endTime', $endTime);
        return $where;
    }
}
